﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Economo.UI.Views;
using Economo.UI.AccountsServiceReference;
using Economo.Services.BusinessEntities;

namespace Economo.UI.Presenters
{
    public class ManageAccountsPresenter : ManageEntitiesPresenter 
    {
        public ManageAccountsPresenter(IManageAccountsView view) : base(view)
        {

        }
        private IManageAccountsView AccountsView
        {
            get
            {
                return (IManageAccountsView)View;
            }
        }



        #region Side Methods
        private Economo.Services.BusinessEntities.Account GetAccountFromGridRow(Int32 rowIndex)
        {
            Economo.Services.BusinessEntities.Account accountOnGridRow = new Economo.Services.BusinessEntities.Account();
            accountOnGridRow.Id = Convert.ToByte(View.GetEntityIdFromGridRow(rowIndex));
            accountOnGridRow.Description = AccountsView.GetAccountDescriptionFromGridRow(rowIndex);
            accountOnGridRow.AccountTypeId = View.GetCellValueFromGridRow<byte>(rowIndex, "AccountTypeId");
            accountOnGridRow.BankId = View.GetCellValueFromGridRow<byte?>(rowIndex, "BankId");
            accountOnGridRow.BankAccountId = View.GetCellValueFromGridRow<Int16?>(rowIndex, "BankAccountId");
            accountOnGridRow.CreditCardId = View.GetCellValueFromGridRow<byte?>(rowIndex, "CreditCardId");
            return accountOnGridRow;
        }
        #endregion
    }
}
